# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=opencl-headers
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=2.2.20170516 # date of the commit, branch 2.1
pkgrel=1
epoch=2
pkgdesc='OpenCL (Open Computing Language) header files'
arch=('any')
url='https://www.khronos.org/registry/cl/'
license=('custom')
makedepends=(git python3)
source=('git+https://github.com/KhronosGroup/OpenCL-Headers.git#commit=ec2566b'
        'git+https://github.com/KhronosGroup/OpenCL-CLHPP.git#commit=e250e2e'
        'LICENSE.txt')
sha256sums=('SKIP'
            'SKIP'
            'd1059405dce021e0c0a7f7e01b48447e641477e0c14a9bc29983f4202b67c410')

prepare() {
  cd "${srcdir}"/OpenCL-CLHPP

  # https://github.com/KhronosGroup/OpenCL-CLHPP/issues/26
  #git cherry-pick -n befe77b66fd3dd87ce9fef940e475cdc71d8bd9f
}

package() {
  cd "${srcdir}"/OpenCL-Headers/opencl22/CL

  install -dm755 "${pkgdir}${MINGW_PREFIX}/include/CL"

  for h in *.h; do
    install -m 644 ${h} "${pkgdir}${MINGW_PREFIX}/include/CL/"
  done

  cd "${srcdir}"/OpenCL-CLHPP

  python3 gen_cl_hpp.py -i input_cl.hpp -o cl.hpp
  install -m 644 cl.hpp "${pkgdir}${MINGW_PREFIX}/include/CL/"
  install -m 644 input_cl2.hpp "${pkgdir}${MINGW_PREFIX}/include/CL/cl2.hpp"

  install -D -m644 ../LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
